//
//  PasswordSetVC.m
//  FitnessCenter
//
//  Created by 铅笔 on 16/3/1.
//  Copyright © 2016年 Hanley. All rights reserved.
//

#import "PasswordSetVC.h"
#import "PaypwdMController.h"//重置支付密码
//#import "UserPwdViewController.h"//重置登录密码
#import "ChangePasswordVC.h"//重置登录密码
#import "PaypwdViewController.h"//设置支付密码
#import "GesturePasswordVC.h"//重置手势密码
@interface PasswordSetVC ()
{
    UIButton *gobackBtn;
    UILabel *content_1lab;
}
@property(nonatomic,strong)PaypwdViewController *paypwdVc;
@property(nonatomic,strong)PaypwdMController *paypwdMVC;
@property(nonatomic,strong)ChangePasswordVC *userPwdViewVC;

@end

@implementation PasswordSetVC

-(PaypwdMController *)paypwdMVC
{
    if (!_paypwdMVC) {
        _paypwdMVC=[[PaypwdMController alloc]init];
    }
    return _paypwdMVC;
}

-(ChangePasswordVC *)userPwdViewVC
{
    if (!_userPwdViewVC) {
        _userPwdViewVC=[[ChangePasswordVC alloc]init];
    }
    return _userPwdViewVC;
}

-(PaypwdViewController *)paypwdVc
{
    if (!_paypwdVc) {
        _paypwdVc=[[PaypwdViewController alloc]init];
    }
    return _paypwdVc;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.navigationController addChildViewController:self];
    
    self.title = @"密码管理" ;
    
    [self showUI];
}

- (void) viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
    self.tabBarController.tabBar.hidden = YES;
    NSLog(@"%@",[[NSUserDefaults standardUserDefaults]objectForKey:@"issetpaypassword"]);
    //展示的 显示
    int  ispasspwd=[[[NSUserDefaults standardUserDefaults]objectForKey:@"issetpaypassword"] intValue];
    
    if (ispasspwd == 1) {
        content_1lab.text=@"重置交易密码";
    }
    else
    {
        content_1lab.text=@"设置交易密码";
    }
}

- (void)showUI
{
    //整个view
    UIView *contentView=[[UIView alloc]initWithFrame:CGRectMake(0,64, ScreenW, ScreenH-64)];
    contentView.backgroundColor = COLOR_EVERYVIEWBG;
    [self.view addSubview:contentView];
    
    //content 1
    UIView *content_1=[[UIView alloc]initWithFrame:CGRectMake(0,0, ScreenW, 45)];
    content_1.backgroundColor = [UIColor whiteColor];
    [contentView addSubview:content_1];
    
    content_1lab=[[UILabel alloc]initWithFrame:CGRectMake(LEFT_SPACING, 8, 130, 25)];
    
    content_1lab.font=[UIFont boldSystemFontOfSize:Font_SIZE_14];
    [content_1 addSubview:content_1lab];
    UIImageView *cimg1=[[UIImageView alloc]initWithFrame:CGRectMake(ScreenW-28, 10, 22, 22)];
    cimg1.image=[UIImage imageNamed:@"return_1"];
    [content_1 addSubview:cimg1];
    content_1lab.textColor = [UIColor grayColor];
    
    //balancedetail
    UIButton *modifyBtn=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, ScreenW, 45)];
    [modifyBtn addTarget:self action:@selector(modifyBtnEvent) forControlEvents:UIControlEventTouchUpInside];
    [content_1 addSubview:modifyBtn];
    
    //content 2
    UIView *content_2=[[UIView alloc]initWithFrame:CGRectMake(0, content_1.y+content_1.height+2, ScreenW, 45)];
    
    content_2.backgroundColor = [UIColor whiteColor];
    [contentView addSubview:content_2];
    
    UILabel *content_2lab=[[UILabel alloc]initWithFrame:CGRectMake(LEFT_SPACING, 8, 130, 25)];
    content_2lab.text=@"登录密码管理";
    content_2lab.font=[UIFont boldSystemFontOfSize:15];
    [content_2 addSubview:content_2lab];
    UIImageView *cimg2=[[UIImageView alloc]initWithFrame:CGRectMake(ScreenW-28, 10, 22, 22)];
    cimg2.image=[UIImage imageNamed:@"return_1"];
    [content_2 addSubview:cimg2];
    content_2lab.textColor = [UIColor grayColor];
    
    //balancedetail
    UIButton *forgetBtn=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, ScreenW, 45)];
    [forgetBtn addTarget:self action:@selector(forgetBtnEvent) forControlEvents:UIControlEventTouchUpInside];
    [content_2 addSubview:forgetBtn];
    
    //content 3
    UIView *content_3 = [[UIView alloc]initWithFrame:CGRectMake(0, content_2.y+content_2.height+2, ScreenW, 45)];
    
    content_3.backgroundColor = [UIColor whiteColor];
    [contentView addSubview:content_3];
    
    UILabel *content_3lab=[[UILabel alloc]initWithFrame:CGRectMake(LEFT_SPACING, 8, 130, 25)];
    content_3lab.text=@"手势密码管理";
    content_3lab.font=[UIFont boldSystemFontOfSize:15];
    [content_3 addSubview:content_3lab];
    UIImageView *cimg3=[[UIImageView alloc]initWithFrame:CGRectMake(ScreenW-28, 10, 22, 22)];
    cimg3.image=[UIImage imageNamed:@"return_1"];
    [content_3 addSubview:cimg3];
    content_3lab.textColor = [UIColor grayColor];
    
     //gesture  start app
    UIButton *button_gesture = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, ScreenW, 45)];
    [button_gesture addTarget:self action:@selector(gestureSetPassword) forControlEvents:UIControlEventTouchUpInside];
    [content_3 addSubview:button_gesture];
}

//重置／设置支付密码
- (void)modifyBtnEvent
{
    int  ispasspwd=[[[NSUserDefaults standardUserDefaults]objectForKey:@"issetpaypassword"] intValue];
    if (ispasspwd==1) {
    
        [self.navigationController pushViewController:self.paypwdMVC  animated:YES];
        
    }
    else
    {
        self.paypwdVc.memberid = [[[NSUserDefaults standardUserDefaults] objectForKey:@"memberid"] intValue];
        self.paypwdVc.payjumpStr=@"PasswordSetVC";
        [self.navigationController pushViewController:self.paypwdVc animated:NO];
    }

}

//重置登录密码
- (void)forgetBtnEvent
{
    [self.navigationController pushViewController:self.userPwdViewVC animated:YES];
}

#pragma mark -- 手势解锁 密码设置
- (void) gestureSetPassword
{

    NSLog(@"ggggg");
    
    GesturePasswordVC *gestureView = [[GesturePasswordVC alloc] init];
    [self.navigationController pushViewController:gestureView animated:NO];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
   
}

@end
